package io.polly.common.entity;

import io.polly.common.constant.NotifyTypeEnum;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ldz
 * @version V1.0
 * @title: NotifyItem
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2022/3/21 13:50
 */
@Data
public class NotifyItem {

    private boolean enabled = true;
    private NotifyTypeEnum type;

    /** alarm parameter*/
    private int threshold;
    private int interval = 120;

    /**
     * Default notify items.
     */
    private static final List<NotifyItem> DEFAULT_NOTIFY_ITEMS;

    static {
        NotifyItem changeNotify = new NotifyItem();
        changeNotify.setType(NotifyTypeEnum.CHANGE);

        NotifyItem activesNotify = new NotifyItem();
        activesNotify.setType(NotifyTypeEnum.ACTIVES);

        NotifyItem capacityNotify = new NotifyItem();
        capacityNotify.setType(NotifyTypeEnum.CAPACITY);
        capacityNotify.setThreshold(80);

        NotifyItem rejectNotify = new NotifyItem();
        rejectNotify.setType(NotifyTypeEnum.REJECT);
        rejectNotify.setThreshold(1);

        DEFAULT_NOTIFY_ITEMS = new ArrayList<>(4);
        DEFAULT_NOTIFY_ITEMS.add(activesNotify);
        DEFAULT_NOTIFY_ITEMS.add(changeNotify);
        DEFAULT_NOTIFY_ITEMS.add(capacityNotify);
        DEFAULT_NOTIFY_ITEMS.add(rejectNotify);
    }

    public static List<NotifyItem> getDefaultNotifyItems() {
        return DEFAULT_NOTIFY_ITEMS;
    }

}
